package gw.com.android.app.dispatch;

import android.app.Activity;

import java.util.Map;

import gw.com.android.model.ConfigType;
import gw.com.android.terminal.GTSDataListener;
import gw.com.android.ui.MainActivity;
import www.com.library.app.AppActivities;
import www.com.library.app.ObjectSessionStore;

/**
 * 分发“首页”中的业务处理类
 * hxgts2://home/
 *
 * @author jett
 * @since 2018-05-16.
 */
public class HomeDispatch implements Dispatch {

    @Override
    public boolean handle(Activity activity, String path, Map<String, String> params) {
        if ("tab".equals(path)) {
            toHomeTab();
            return true;
        }
        return false;
    }

    /**
     * hxgts2://home/tab/
     */
    private void toHomeTab() {
        AppActivities.getSingleton().popAllActivityExceptOne(MainActivity.class.getSimpleName());
        MainActivity mainActivity = (MainActivity) ObjectSessionStore.getObject(MainActivity.class.getSimpleName() + GTSDataListener.mainNum);
        if (mainActivity != null) {
            mainActivity.setTabFragment(ConfigType.TAB_HOME_TAG, "");
        }
    }

}
